/**
 * 播放声音
 */
;

function initPlaySound()
{
	$("body").append("<div id='jquery_jplayer'></div>")
	
	$("#jquery_jplayer").jPlayer({
		swfPath: "/webjars/jplayer/2.9.2/dist/jplayer",
		supplied: "mp3",
		cssSelectorAncestor: "",
		size: {
		  width: "1px",
		  height: "1px"
		},
		play: function(event) {
			//console.log("play sound start.");
		},
		ended: function(event) {
			$(this).jPlayer("play");
			//console.log("play sound end.");
		},
		error: function(event) {
			console.log("play sound error.");
		}
	});
}

function playSound()
{
	$("#jquery_jplayer").jPlayer("stop");
	$("#jquery_jplayer").jPlayer("setMedia", {
		mp3: "/alarm/sounds/alert.mp3"
	});
	$("#jquery_jplayer").jPlayer("play");
}

function stopSound()
{
	$("#jquery_jplayer").jPlayer("stop");
}

//真人语音
function speach(text){
	var utterThis = new window.SpeechSynthesisUtterance(text);
	utterThis.onstart = function(event){
		stopSound();
	}
	
	utterThis.onend = function(event){
		playSound();
	}
	window.speechSynthesis.speak(utterThis);
}



